
//
//	This file tests handling one or more sources and reporting the correct position for errors/warnings
//

files = {
	'a.js': 'a = b',
	'b.js': 'b = c',
	'index.html':
		'<script src="a.js"></script>\n' +
		'<body onload="ha = null">\n' +
			'<script src="test/b.js"></script>\n' +
			'<script>a = 0</script>\n' +
			'<script type="text/javascript">b = 0\n' +
			'// multiline!</script>\n' +
		'</body>',
	'test/a.js': '',
	'test/b.js': 'b = c',
	'test/b1.js': 'c = 1',
	'test/readme.html':
		'<script src="b1.js"></script>\n' +
		'<script src="./a.js"></script>\n' +
		'<script src="*.js"></script>\n' +	// does not exist
		'<script src="test/b.js"></script>'	// does not exist either
};
dirs = {
	'.': ['a.js', 'b.js', 'index.html'],
	'test': ['a.js', 'b.js', 'b1.js', 'readme.html']
};

// test #1
doTest([
	'a = b',
	'b = c',
	'a; c = d;'
], [
	[3001, 1, 5, 0], [3001, 1, 5, 1],				// missing semicolon
	[2001, 1, 1, 0], [2001, 1, 1, 1], [2001, 1, 4, 2]	// assignment to undeclared identifier
]);

// test #2
doTest([
	'a.js',
	'b.js'
], [
	[3001, 1, 5, 0], [3001, 1, 5, 1],	// missing semicolon
	[2001, 1, 1, 0], [2001, 1, 1, 1]	// assignment to undeclared identifier
]);

// test #3
doTest([
	'*.js'
], [
	[3001, 1, 5, 0], [3001, 1, 5, 1],	// missing semicolon
	[2001, 1, 1, 0], [2001, 1, 1, 1]	// assignment to undeclared identifier
]);

// test #4
doTest([
	'index.html'
], [
	// 0 = a.js	; 1 = b.js; 2 = inline script #1; 3 = inline script #2; 4 = body onload; 
	[3001, 1, 5, 0], [3001, 1, 5, 1], [3001, 4, 13, 2], [3001, 5, 36, 3], [3001, 2, 23, 4],	// missing semicolon
	[2001, 1, 1, 0], [2001, 1, 1, 1], [2001, 4,  9, 2], [2001, 5, 32, 3], [2001, 2, 15, 4]	// assignment to undeclared identifier
]);

// test #5
doTest([
	'test/readme.html'
], [
	// 0 = test/b1.js
	[3001, 1, 5, 0],	// missing semicolon
	[2001, 1, 1, 0]	// assignment to undeclared identifier
]);
